/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidad;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author a
 */
@Entity
@Table(name = "mesa")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Mesa.findAll", query = "SELECT m FROM Mesa m"),
    @NamedQuery(name = "Mesa.findByIdMesa", query = "SELECT m FROM Mesa m WHERE m.idMesa = :idMesa"),
    @NamedQuery(name = "Mesa.findByNumeroMesa", query = "SELECT m FROM Mesa m WHERE m.numeroMesa LIKE :numeroMesa"),
    @NamedQuery(name = "Mesa.findByCantidadPersona", query = "SELECT m FROM Mesa m WHERE m.cantidadPersona = :cantidadPersona"),
    @NamedQuery(name = "Mesa.findByDescripcion", query = "SELECT m FROM Mesa m WHERE m.descripcion LIKE :descripcion")})
public class Mesa implements Serializable {
     @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idMesa")
    private Integer idMesa;
    @Basic(optional = false)
    @Column(name = "numeroMesa")
    private int numeroMesa;
    @Column(name = "cantidadPersona")
    private Integer cantidadPersona;
    @Column(name = "descripcion")
    private String descripcion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "mesaidMesa")
    private Collection<Orden> ordenCollection;

    public Mesa() {
    }

    public Mesa(Integer idMesa) {
        this.idMesa = idMesa;
    }

    public Mesa(Integer idMesa, int numeroMesa) {
        this.idMesa = idMesa;
        this.numeroMesa = numeroMesa;
    }

    public Integer getIdMesa() {
        return idMesa;
    }

    public void setIdMesa(Integer idMesa) {
        Integer oldIdProveedores = this.idMesa;
        this.idMesa = idMesa;
        changeSupport.firePropertyChange("idMesa", oldIdProveedores, idMesa);
    }

    public int getNumeroMesa() {
        return numeroMesa;
    }

    public void setNumeroMesa(int numeroMesa) {
        int oldNombre = this.numeroMesa;
        this.numeroMesa = numeroMesa;
        changeSupport.firePropertyChange("numeroMesa", oldNombre, numeroMesa);
    }

    public Integer getCantidadPersona() {
        return cantidadPersona;
    }

    public void setCantidadPersona(Integer cantidadPersona) {
        Integer oldIdProveedores = this.cantidadPersona;
        this.cantidadPersona = cantidadPersona;
        changeSupport.firePropertyChange("cantidadPersona", oldIdProveedores, cantidadPersona);
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        String oldIdProveedores = this.descripcion;
        this.descripcion = descripcion;
        changeSupport.firePropertyChange("descripcion", oldIdProveedores, descripcion);
    }

    @XmlTransient
    public Collection<Orden> getOrdenCollection() {
        return ordenCollection;
    }

    public void setOrdenCollection(Collection<Orden> ordenCollection) {
        this.ordenCollection = ordenCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMesa != null ? idMesa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Mesa)) {
            return false;
        }
        Mesa other = (Mesa) object;
        if ((this.idMesa == null && other.idMesa != null) || (this.idMesa != null && !this.idMesa.equals(other.idMesa))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Mesa: " + numeroMesa ;
    }
    
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
